﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ConcordWinManager
{
    public partial class AllReportForm : Form
    {
        public AllReportForm()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            MSExcelReportGenerator ms = new MSExcelReportGenerator();

            bool deleted;

            if (cbxType.SelectedIndex == 0)
            {
                deleted = false;
            }
            else
            {
                deleted = true;
            }

            if (rbtnOplata.Checked)
            {
                Tools.RunWithProgressIndicator(this, delegate
                {
                    ms.GenerateReportByOplata(dateTimePickerBegin.Value, dateTimePickerEnd.Value, deleted);
                });
            }
            else if (rbtnContract.Checked)
            {
                Tools.RunWithProgressIndicator(this, delegate
                {
                    ms.GenerateReportContract(dateTimePickerBegin.Value, dateTimePickerEnd.Value, deleted);
                });
            }
            else if (rbtnRassrochka.Checked)
            {
                Tools.RunWithProgressIndicator(this, delegate
                   {
                       ms.GenerateReportRassrochka(dateTimePickerBegin.Value, dateTimePickerEnd.Value, deleted);
                   });
            }
            else if (rbtnNeoplatRassochka.Checked)
            {
                Tools.RunWithProgressIndicator(this, delegate
                {
                    ms.GenerateReportNeoplatRassrochka2(dateTimePickerBegin.Value, dateTimePickerEnd.Value, deleted);
                });
            }
        }

        private void AllReportForm_Load(object sender, EventArgs e)
        {
            dateTimePickerBegin.Value = new DateTime(DateTime.Now.Year, 01, 01);
            cbxType.SelectedIndex = 0;
        }
    }
}